#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMap>
#include <QTimer>
#include "StatusWidget.h"
#include "UCommunication/UCommunication.h"

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();


protected:
    void changeEvent(QEvent *e);
    bool eventFilter(QObject *target, QEvent *event);

private:
    Ui::MainWindow *ui;
    QTimer *timer;
    StatusWidget *statusWidget;
    UCommunication *uCom;
    QByteArray textSDec;

    QMap<QString, int> mapClient;
private:
    int SendText(QByteArray sendData,int length);
    void DisplayText(const char *data, quint64 maxSize);
    void InitTcpServer();
private slots:
    void on_pushSendOpen_clicked();
    void on_pushRecvSave_clicked();
    void on_pushOpenCom_clicked();
    void on_pushLinkTCPS_clicked();
    void on_pushCreateTCPS_clicked();
    void on_pushOpenLink_clicked();
    void on_checkBoxRecvPause_clicked(bool checked);
    void on_checkBoxRecvHex_clicked(bool checked);
    void on_checkBoxRecvNewL_clicked(bool checked);
    void on_checkBoxSendCircle_clicked(bool checked);
    void on_pushSend_clicked();
    void on_checkBoxSendClear_clicked(bool checked);
    void on_pushSendClear_clicked();
    void on_pushRecvClear_clicked();
    void on_checkBoxSendHex_clicked(bool checked);
    void on_comboBox_currentIndexChanged(int index);

    void slotDataCom(const char * data, quint64 maxSize);
    void slotDataCom(QByteArray data, int size);
    void slotComingConnection(QString ip, quint16 port);
    void slotDeleteConnection(QString ip, quint16 port);
    void slotCircleSend();

    void slotTcpClientConn(QString ip, quint16 port);
    void slotTcpClientDiscon();
    void slotTcpClientError(QString error);
};

#endif // MAINWINDOW_H
